<template>
  <view class="category">
    <navigator
      class="img_wrap"
      v-for=" item in category"
      :key="item.id"
      :url="`/pages/imgCategory/index?id=${item.id}`"
    >
      <image
        mode="aspectFill"
        :src="item.cover"
      ></image>
      <view class="text">{{item.name}}</view>
    </navigator>
  </view>

</template>

<script>
export default {
  data () {
    return {
      category: []
    }
  },
  mounted () {
    //修改页面的标题
    uni.setNavigationBarTitle({ title: '分类' })
    this.getCate()
  },
  methods: {
    // 获取评论列表
    async getCate () {
      const res = await this.$request({ url: '/image/v1/vertical/category' })
      this.category = res.category
      console.log(this.category);
    }
  }

}
</script>

<style lang='scss' scope>
.category {
  display: flex;
  flex-wrap: wrap;
  .img_wrap {
    width: 33.33vw;
    height: 33.33vw;
    border: 5rpx solid #ffffff;
    position: relative;
    image {
      width: 100%;
      height: 100%;
    }
    .text {
      color: #ffffff;
      font-size: 35rpx;
      position: absolute;
      bottom: 10rpx;
      left: 20rpx;
    }
  }
}
</style>